package com.sunday.electric.ui.mine;

import android.os.Bundle;

import com.sunday.common.widgets.EmptyLayout;
import com.sunday.electric.R;
import com.sunday.electric.base.BaseActivity;
import com.sunday.electric.ui.XWalkExUiClient;

import org.xwalk.core.XWalkPreferences;
import org.xwalk.core.XWalkResourceClient;
import org.xwalk.core.XWalkView;
import org.xwalk.core.XWalkWebResourceRequest;
import org.xwalk.core.XWalkWebResourceResponse;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2016/1/14.
 */
public class NoticeActivity extends BaseActivity {
    @Bind(R.id.webView)
    XWalkView mXWalkView;
    @Bind(R.id.empty_layout)
    EmptyLayout emptyLayout;
    String url = "http://202.110.130.19:1080/RedAS/app/appPage.go?method=goAppInformationPage";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_notice);
        ButterKnife.bind(this);
        mXWalkView.load(url, null);
        emptyLayout.setErrorType(EmptyLayout.NETWORK_LOADING);
        mXWalkView.setUIClient(new XWalkExUiClient(mXWalkView));
        XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING, true);
        //   mXWalkView.load("javascript:document.body.contentEditable=true;", null);
        mXWalkView.setResourceClient(new XWalkResourceClient(mXWalkView) {

            @Override
            public void onReceivedLoadError(XWalkView view, int errorCode, String description, String failingUrl) {
                emptyLayout.setErrorType(EmptyLayout.NETWORK_ERROR);
                super.onReceivedLoadError(view, errorCode, description, failingUrl);
            }

            @Override
            public void onLoadFinished(XWalkView view, String url) {
                emptyLayout.setErrorType(EmptyLayout.HIDE_LAYOUT);
                super.onLoadFinished(view, url);
            }

            @Override
            public XWalkWebResourceResponse shouldInterceptLoadRequest(XWalkView view, XWalkWebResourceRequest request) {
                return super.shouldInterceptLoadRequest(view, request);
            }

            @Override
            public void onLoadStarted(XWalkView view, String url) {
                super.onLoadStarted(view, url);
            }
        });
    }

}
